package com.mininglamp.main;

import org.kie.api.KieBaseConfiguration;
import org.kie.api.io.ResourceType;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.StatefulKnowledgeSession;

import java.io.StringReader;



public class TestMain {
    public static class Foo {
        private int value;
        public Foo(int value) {
            this.value = value;
        }
        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }
    }
    private final static String rule = "" +
            "package test\n" +
            "import com.test.Main.Foo;\n" +
            "rule test\n" +
            "\twhen\n" +
            "\t\tFoo($p : value > 20)\n" +
            "\tthen\n" +
            "\t\tSystem.out.println(\"Fired\");\n" +
            "end";

    public static void main(String[] args) throws Exception {
//        KieBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); //1
////        conf.setOption(MultithreadEvaluationOption.YES); //2
////        conf.setOption(MaxThreadsOption.get(10)); //3
//        KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase(conf); //4
//        //5
//        KnowledgeBuilder bld = KnowledgeBuilderFactory.newKnowledgeBuilder(); //6
//        bld.add(ResourceFactory.newReaderResource(new StringReader(rule)), ResourceType.DRL); //7
//        kb.addKnowledgePackages(bld.getKnowledgePackages()); //8
//        //9
//        StatefulKnowledgeSession session = kb.newStatefulKnowledgeSession(); //10
//        session.insert(new Foo(25)); //11
//        //12
//        session.fireAllRules(); //13
    }
}